home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5484 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 100754.2730@compuserve.com (Martin Aupperle)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: [] overload..(newbie in distress)
  5. Date: Sun, 04 Feb 1996 21:56:14 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4f3adi$aap@dub-news-svc-2.compuserve.com>
  8. References: <DLGppJ.31C@undergrad.math.uwaterloo.ca>  <Robert.Lendvai-2101960118330001@129.170.80.94>  <4dtuam$hf4@news.xmission.com>  <ALUN.CHAMPION.96Jan22143422@g7240065.bridge.bst.bls.com>  <4e12is$5no@engnews1.Eng.Sun.COM> <ALUN.CHAMPION.96Jan23151559@g7240065.bridge.bst.bls.com>
  9. NNTP-Posting-Host: ad21-080.compuserve.com
  10. X-Newsreader: Forte Free Agent v0.56
  11.  
  12. Alun.Champion@bridge.bst.bls.com (Alun Champion) wrote:
  13.  
  14. >In article <4e12is$5no@engnews1.Eng.Sun.COM> RAJU ALLURI <raju.alluri@Sun.COM> writes:
  15.  
  16. >: Instead, if you use the third type of function for the constant objects,
  17. >: then some wicked fellow like me can do like
  18. >       (int &)(ca[2]) = 200;
  19. >: and make the constant object changed!
  20.  
  21. >This doesn't really hold much weight as some wicked fellow like me can
  22. >circumvent the constness of the ARRAY anyway like:
  23.  
  24. >           ((Array&)ca)[2] = 200;
  25.  
  26. It does hold very much weight, because if you use type casts, you
  27. cannot argue about types any more. You loose all advantages of a
  28. strongly typed language. If you say explicitely to the compiler that a
  29. memory location has an object of type B where the creator created an
  30. object of type A, the compiler will allow to access the A object with
  31. B's semantics. Is this what you want? In that special case? In
  32. gegeral?
  33.  
  34. This is the reason why there is a big difference between a cast that
  35. the compiler can do internally and an cast where an explicit notation
  36. is needed. The latter is a relict from VERY low level languages and
  37. should be generally banned from C++ (EXCEPT the one case: downcasting
  38. in an inheritance hierarchy, which is a language design flaw IMO). 
  39.  
  40. Martin
  41.  
  42.  
  43.  
  44. -----------------------------------
  45. Signatures are a waste of bandwidth
  46. -----------------------------------
  47.  
  48.